package com.yunji.aggregate.mapper;

import com.yunji.aggregate.model.dto.analysis.HomeDataParam;
import com.yunji.aggregate.model.dto.analysis.TradeCountParam;
import com.yunji.aggregate.model.dto.analysis.WalletTurnoverParam;
import com.yunji.aggregate.model.dto.container.FillCargoParam;
import com.yunji.aggregate.model.dto.stock.StatisticsDataParam;
import com.yunji.aggregate.model.vo.analysis.EarnTrendVO;
import com.yunji.aggregate.model.vo.analysis.FillCargoLocationVO;
import com.yunji.aggregate.model.vo.analysis.SaleTrendVO;
import com.yunji.aggregate.model.vo.base.WalletTurnoverVO;
import com.yunji.aggregate.model.vo.container.CabinetCellVO;
import com.yunji.aggregate.model.vo.container.FillCargoContainerVO;
import com.yunji.aggregate.model.vo.container.FillCargoProductVO;
import com.yunji.aggregate.model.vo.product.PricingProductStatisticsVO;
import com.yunji.common.annotation.DataScope;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author : peter-zhu
 * @date : 2024/12/16 16:42
 * @description : TODO
 **/
public interface IAnalysisComplexMapper {

    @DataScope
    List<SaleTrendVO> salesStats(StatisticsDataParam param);

    /**
     * 根据param查看成功订单数据
     *
     * @return
     */
    Integer selectCountByTradeParam(@Param("param") TradeCountParam tradeParam);

    Integer countPricingProduct(@Param("param") PricingProductStatisticsVO response);
    /*-------------------------------------------管理端数据统计------------------------------------------*/

    @DataScope
    @Select(" SELECT DATE_FORMAT(tra.create_time,'%m-%d') AS date, IFNULL(SUM(tra.trade_amount),0) AS earnAmount  FROM t_trade tra " +
            "WHERE tra.api_time >= #{beginTime}  AND tra.api_time <= #{closeTime} AND tra.trade_type = #{earnType}  GROUP BY date ")
    List<EarnTrendVO> countOrderEarnsOfDay(@Param("para") HomeDataParam param,@Param("earnType") Integer earnType, @Param("beginTime") LocalDateTime beginTime, @Param("closeTime") LocalDateTime closeTime);

    @DataScope
    @Select(" SELECT DATE_FORMAT(tra.create_time,'%Y-%m') AS date,IFNULL(SUM(tra.trade_amount),0) AS earnAmount  FROM t_trade tra " +
            "WHERE tra.api_time >= #{beginTime}  AND tra.api_time <= #{closeTime} AND tra.trade_type = #{earnType} GROUP BY date ")
    List<EarnTrendVO> countOrderEarnsOfMonth(@Param("param") HomeDataParam param,@Param("earnType") Integer earnType, @Param("beginTime") LocalDateTime beginTime, @Param("closeTime") LocalDateTime closeTime);

    @DataScope
    List<EarnTrendVO> earnsStatsByDay(StatisticsDataParam param);

    List<WalletTurnoverVO> walletTurnoverList(WalletTurnoverParam param);

    List<FillCargoContainerVO> fillCargoContainerList(FillCargoParam cabinetParam);

    List<CabinetCellVO> getCellsById(@Param("cabinetIds") List<Long> cabinetIds);

    List<FillCargoProductVO> fillCargoProductList(FillCargoParam cabinetParam);

    List<FillCargoContainerVO> searchFillCargoList(FillCargoParam fillCargoParam);

    List<FillCargoLocationVO> fillCargoLocation(FillCargoParam param);

    List<CabinetCellVO> getLockCabinetCell(@Param("containerIds") List<Long> containerIds);

    List<Long> getContainerIds(Long belongId);
}
